package com.jingdianjichi.auth.domain.service.impl;

import com.jingdianjichi.auth.common.enums.IsDeleteEnum;
import com.jingdianjichi.auth.domain.convert.AuthRoleBOConverter;
import com.jingdianjichi.auth.domain.entity.AuthRoleBO;
import com.jingdianjichi.auth.domain.service.AuthRoleDomainService;
import com.jingdianjichi.auth.infra.basic.entity.AuthRole;
import com.jingdianjichi.auth.infra.basic.service.AuthRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {

    @Resource
    private AuthRoleService authRoleService;
    @Override
    public Boolean add(AuthRoleBO authRoleBO) {
        AuthRole authRole= AuthRoleBOConverter.Instance.convertBOToEntity(authRoleBO);
        authRole.setIsDeleted(IsDeleteEnum.UN_DELETED.getCode());
        return authRoleService.insert(authRole)>0;
    }

    /**
     * 新增角色信息
     * @param authRoleBO
     * @return
     */
    @Override
    public Boolean update(AuthRoleBO authRoleBO) {
        AuthRole authRole= AuthRoleBOConverter.Instance.convertBOToEntity(authRoleBO);
        return authRoleService.update(authRole)>0;
    }

    @Override
    public Boolean delete(AuthRoleBO authRoleBO) {
        AuthRole authRole=new AuthRole();
        authRole.setId(authRoleBO.getId());
        authRole.setIsDeleted(IsDeleteEnum.DELETED.getCode());
        return authRoleService.update(authRole)>0;
    }
}
